//
//  DYLoginVC.m
//  kafuMerchant
//
//  Created by 帝云科技 on 2018/9/10.
//  Copyright © 2018年 帝云科技. All rights reserved.
//

#import "DYLoginVC.h"
#import "DYLoginView.h"
#import "IQKeyboardManager.h"
#import "DYRegisterVC.h"
#import "DYNavigationController.h"
#import "DYForgotPasswordVC.h"

@interface DYLoginVC ()

@property (nonatomic,strong)DYLoginView *loginView;

@end

@implementation DYLoginVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view
    [self createLeftBarItem:@"nav_back" titleString:nil];
}
-(void)dy_initUI
{
    [super dy_initUI];
    
    [self.view addSubview:self.loginView];

}
-(void)leftButtonClick
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
-(DYLoginView *)loginView
{
    if (!_loginView) {
        _loginView=[[DYLoginView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight-kNavigationStatusHeight)];
        
        @weakify(self);
        _loginView.registerBlock = ^{
            @strongify(self);
            DYRegisterVC *vc=[[DYRegisterVC alloc]init];
            DYNavigationController *nav=[[DYNavigationController alloc]initWithRootViewController:vc];
            [self presentViewController:nav animated:YES completion:nil];
        };
        
        _loginView.forgotPasswordBlock = ^{
            @strongify(self);
            DYForgotPasswordVC *vc=[[DYForgotPasswordVC alloc]init];
            DYNavigationController *nav=[[DYNavigationController alloc]initWithRootViewController:vc];
            [self presentViewController:nav animated:YES completion:nil];
        };
    }
    return _loginView;
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    //TODO: 页面appear 禁用
    [[IQKeyboardManager sharedManager] setEnable:NO];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
    //TODO: 页面Disappear 启用
    [[IQKeyboardManager sharedManager] setEnable:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
